package cn.doitedu.day02

import scala.collection.mutable

/**
 * 可变的HashMap
 */
object HashMapDemo2 {

  def main(args: Array[String]): Unit = {

    val m1 = new mutable.HashMap[String, Int]

    m1.put("a", 1)
    m1 += (("b", 2), ("c", 3))
    m1("d") = 4

    for (entry <- m1) {
      println(entry._1 + " , " + entry._2)
    }

    println("----------")

    //删除一个key
    m1.remove("d")

    m1 -= "a"

    //map中装的是一个或多个对偶元组，对偶元组的_1是key，_2是value
    for (entry <- m1) {
      println(entry._1 + " , " + entry._2)
    }


  }

}
